<template>
  <div>
    <el-form ref="form" :model="form" label-width="100px">
      <el-form-item label="供应商编号">
        <el-input v-model="form.id"  :disabled='true'></el-input>
      </el-form-item>
      <el-form-item label="供应商名称">
        <el-input v-model="form.name"></el-input>
      </el-form-item>

      <el-form-item label="联系方式">
        <el-input v-model="form.phone"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">确认</el-button>
        <el-button @click="reset">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import axios from "axios";
import qs from 'qs'
export default {
  data() {
    return {
      form: {
        name: "",
        id: "",
        phone: "",
      },
    };
  },
  methods: {
    onSubmit() {
      axios({
        url:'http://localhost:3000/editS',
        method:'post',
        data:qs.stringify(this.form)
      })
      history.back()
    },
    reset(){
      this.$router.push('/supplier')
    }
  },
  mounted() {
    axios({
      method: "get",
      url: "http://localhost:3000/supplierInfo",
      params: {
        id: this.$route.query.i,
      },
    }).then((success) => {
      this.form.name = success.data.sName;
      this.form.id = success.data.sID;
      this.form.phone = success.data.phone;
    });
  },
};
</script>

<style scoped>
</style>